//
// Created by Jisam on 2024/7/13.
//
#include "bits/stdc++.h"

using  namespace  std;
int main(){
    int n;
    while (cin >> n){
        if(n == 0) break;
        int a = 0;
        int b = 0;
        int s = 0;
        for(int i = 0 ; i < n ; i ++){
            cin >> b;
            if(a < b) s+= (b - a) * 6 + 5;
            else if(a > b) s+= (a - b) * 4 + 5;
            else s+= 5;
            a = b;
        }
        cout << s <<"\n";
    }
    return 0;
}